<template>
  <div class="editMyinfo">
    <van-nav-bar
      title="修改个人信息"
      right-text="保存"
      @click-right="baocun"
      left-arrow
      @click-left="$router.back()"
    />
    <van-cell-group inset>
      <van-field v-model="xuexiao" />
    </van-cell-group>
  </div>
</template>
<script>
import { toRefs, reactive, onMounted } from 'vue'
import { useCounterStore } from '@/stores/counter'
import { editUserNameApi } from '@/http/api'
import { useRouter } from 'vue-router'
export default {
  setup(props) {
    const router = useRouter()
    const store = useCounterStore()
    const data = reactive({
      xuexiao: ''
    })
    const baocun = async () => {
      const res = await editUserNameApi({
        id: store.res.id,
        major: data.xuexiao
      })
      console.log(res)
      if (res.code == 200) {
        router.push({ path: '/info', query: { name: data.xuexiao } })
      }
    }
    return {
      ...toRefs(data),
      baocun
    }
  }
}
</script>
<style lang="scss" scoped>
.home {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
</style>
